{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAARIklEQVR4nO3db4xcV33G8e+DEwItqDj1JjK2qdPItDiocejWRaWtAkFNSF84kUjltAoRimqqJi1IvCDJi4aqshQk/lRVG5CBCLcCXAtC49IANS40RUDCBpkkTkhxSZostuLlXyFUSmvn1xd7I6b2rne8M7POnP1+pNHce+65d37Hu/vsnbN3rlNVSJLa8rzTXYAkafgMd0lqkOEuSQ0y3CWpQYa7JDXojNNdAMCqVatq/fr1p7sMSRor991333eramKubc+JcF+/fj1TU1OnuwxJGitJ/nO+bU7LSFKDDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSg54Tn1CVpFFYf+M/9dXvsVt/d8SVLD3P3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KDvBSyccv5UjBpOfPMXZIatOCZe5IXAHcDZ3X9P1FVtyR5J/CHwEzX9eaquqvb5ybgOuAY8KdV9bkR1C49p/guSc8l/UzLPA28rqqeSnIm8KUkn+m2va+q3t3bOclGYCtwAfBS4PNJXl5Vx4ZZ+GL4wydpuVhwWqZmPdWtntk96iS7bAF2VdXTVfUocBDYPHClkqS+9TXnnmRFkv3AEWBvVd3Tbbohyf1Jbk+ysmtbAzzRs/t013b8MbclmUoyNTMzc/xmSdIA+gr3qjpWVZuAtcDmJK8E3g+cD2wCDgPv6bpnrkPMccwdVTVZVZMTExOLKl6SN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mH8DWNktv2E5jLmn378AdwFvPN11L8HX+SXAQ8DLuvVzTnfdSzDmm4F3dcsTwPeB55/u2gcY828DrwIenGf70PNrXM7c+7mdwRbgb2vWV4GXJFm91IUO0YJjrqovV9UPutWvMvt5gnHW720r/gT4JHBkKYsbkX7G/PvAHVX1OEBVjfu4+xlzAS9OEuBFzIb70aUtc3iq6m5mxzCfoefXuIT7XLczWLOIPuPkVMdzHbO/+cfZgmNOsga4EvjAEtY1Sv18nV8OrEzyxST3JXnTklU3Gv2M+a+BVzD74ccHgLdW1TNLU95pMfT8GtXtB4ZtwdsZ9NlnnPQ9niSvZTbcf3OkFY1eP2P+S+AdVXVs9qRu7PUz5jOAXwUuAV4IfCXJV6vq30dd3Ij0M+ZLgf3A64Dzgb1J/q2qfjTq4k6ToefXuIR7P7czaO2WB32NJ8mvAB8C3lBV31ui2kalnzFPAru6YF8FXJ7kaFX9w9KUOHT9fm9/t6p+Avwkyd3AhcC4hns/Y34zcGvNTkgfTPIo8MvAvUtT4pIben6Ny7RMP7cz2AO8qfur86uB/6qqw0td6BAtOOYkLwPuAK4Z47O4XguOuarOq6r1VbUe+ATwx2Mc7NDf9/adwG8lOSPJzzB7h9WHl7jOYepnzI8z+06FJOcCvwR8e0mrXFpDz6+xOHOveW5nkOSPuu0fYPbKicuBg8B/M/ubf2z1OeY/A34euK07kz1aY3xHvT7H3JR+xlxVDyf5LHA/8Azwoaqa85K6cdDn1/kvgI8keYDZKYt3VNXY3go4yceBi4FVSaaBW4AzYXT55e0HJKlB4zItI0k6BYa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJatD/Ae8C85VUrqjeAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data_uniform = np.random.random_sample((10000))\n",
    "plt.hist(data_uniform, bins=30)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x1 = np.random.randint(1,10,(100))\n",
    "x1.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x: [0 1 2 3 4 5 6 7 8 9]\n",
      "x: [2 8 9 7 0 4 3 1 6 5]\n"
     ]
    }
   ],
   "source": [
    "x = np.arange(10)\n",
    "print('x:',x)\n",
    "np.random.shuffle(x) # 打乱并更改数组本身\n",
    "\n",
    "print('x:',x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x: [0 1 2 3 4 5 6 7 8 9]\n",
      "x: [0 1 2 3 4 5 6 7 8 9]\n",
      "y: [3 9 5 8 0 2 1 6 7 4]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "x = np.arange(10)\n",
    "\n",
    "print('x:',x)\n",
    "y = np.random.permutation(x) # 不改变数组本身\n",
    "\n",
    "print('x:',x)\n",
    "print('y:',y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1.1174789121917164"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 随机种子\n",
    "np.random.seed()\n",
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.28945860455604205"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-2.136196095668454"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.6243453636632417"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(1)\n",
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.6243453636632417"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(1)\n",
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.4167578474054706"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(2)\n",
    "np.random.randn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
